package com.control.mbtc.activitys;

import androidx.fragment.app.Fragment;

import com.control.mbtc.R;
import com.control.mbtc.fragments.account.LoginFragment;
import com.control.mbtc.fragments.account.RegisterFragment;
import com.control.mbtc.fragments.account.TargView;
import com.zzyd.common.app.AppActivity;

/**
 * @author wjunjie
 * @version 1.0
 * @E-mail wang_junjie007@163.com
 * @company ZZYD
 * @createTime 2018/7/16 10:41
 * @类注释: 账户管理
 */
public class AccountActivity extends AppActivity implements TargView {
    private Fragment mCurFragrament;
    private Fragment mLonginFrg;
    private Fragment mRegisterFrg;
    @Override
    protected int getContentLayoutId() {
        return R.layout.activity_account_layout;
    }

    @Override
    protected void initWidget() {
        super.initWidget();
        mCurFragrament = mLonginFrg = new LoginFragment();
        getSupportFragmentManager().beginTransaction()
                .add(R.id.lay_center, mCurFragrament)
                .commit();
    }

    /**
     * fragment切换回调
     */
    @Override
    public void viewTarg() {
        Fragment fragment;
        if (mCurFragrament == mLonginFrg) {
            if (mRegisterFrg == null) {
                mRegisterFrg = new RegisterFragment();
            }
            fragment = mRegisterFrg;
        } else {
            fragment = mLonginFrg;
        }
        mCurFragrament = fragment;
        getSupportFragmentManager().beginTransaction()
                .replace(R.id.lay_center, mCurFragrament)
                .commit();
    }
}
